
use POLLS1517_NATURE.dta, clear

egen mean_mae = mean(mae_avg), by(election)
egen mean_mae_lead = mean(mae_lead), by(election)

label variable id "Election"
label define id 1 "GB 2015" 2 "Denmark 2015" 3 "Greece 2015" 4 "Canada 2015" 5 "Ireland 2016" 6 "Spain 2016" 7 "Australia 2016" 8 "Iceland 2016" 9 "U.S. 2016" 10 "France 2017 (R1)" 11 "France 2017 (R2)" 12 "GB 2017", replace 
label values id id

sum mean_mae

*
twoway /* 
*/ (scatter mae_avg id, jitter(1) mcolor(gs9) mlabel() msymbol(Oh)) /* 
*/ (scatter mean_mae id, mcolor(black) mlabel() msymbol(O)) /* 
*/ , scheme(plottig) graphregion(color(white)) /*
*/ xtitle("", size(medsmall)) /*
*/ xscale(titlegap(2)) /*
*/ xscale(r(0.5 14.2)) /*
*/ xtick(1(1)11) /*
*/ xlabel(1 `""GB" "2015""' 2 `""Denmark" "2015""' 3 `""Greece" "2015""' 4 `""Canada" "2015""' 5 `""Ireland" "2016""' 6 `""Spain" "2016""' 7 `""Australia" "2016""' 8 `""Iceland" "2016""' 9 `""U.S." "2016""' 10 `""France" "2017" "(R1)""' 11 `""France" "2017" "(R2)""' 12 `""GB" "2017""', labsize(vsmall)) /*
*/ yline(2.29, lcolor(black) lpattern(shortdash)) /*
*/ text(2.65 12.4 "{bf: AE (1942-2014) = 2.3}", place(se) box just(left) color(black) bcolor(gs14) size(vsmall)) /*
*/ ytick(0(2)8) /*
*/ ylabel(0(2)8) /*
*/ ylabel(,angle(horizontal)) /*
*/ ytitle("Absolute error", size(medsmall))  /*
*/ title("", size(medsmall))  /*
*/ legend(off) /*
*/ saving(Fig3.gph, replace)

graph export PollError_Fig3.png, width(2000)
graph export PollError_Fig3.eps




